package com.wva.minio.utils;

import io.minio.MinioClient;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;

/**
 * @Author: hong
 * @Date: 2025/2/9 21:04:57
 */
@Getter
public class MinIOUtils {
    @Value("${minio.endpoint}")
    private String endpoint;

    @Value("${minio.accessKey}")
    private String accessKey;

    @Value("${minio.secretKey}")
    private String secretKey;

    private MinioClient minioClient;

    public MinioClient getClient() {
        if (minioClient == null) {
            minioClient = MinioClient.builder()
                    .endpoint(endpoint)
                    .credentials(accessKey, secretKey)
                    // .region("china-south-jieyang")
                    .build();
        }
        return minioClient;
    }
}
